import 'package:flutter/material.dart';
import 'package:flutter_mall_app/pages/product/child_product_list.dart';
import '../../model/CategoryModel.dart';

class RightProductPage extends StatefulWidget {
  final List<BxMallSubDto> list;

  const RightProductPage({Key key, this.list}) : super(key: key);

  @override
  _RightProductPageState createState() => _RightProductPageState();
}

class _RightProductPageState extends State<RightProductPage> with TickerProviderStateMixin{

  TabController _controller;
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    _controller = TabController(length: widget.list.length, vsync: this);
    return Expanded(
      child: Scaffold(
        appBar: AppBar(
          elevation: 0,
          title: TabBar(
              controller: _controller,
              isScrollable: true,
              labelPadding: EdgeInsets.only(top:20,bottom: 15,right: 10,left: 10),
              unselectedLabelColor: Colors.white.withOpacity(0.4),
              tabs: widget.list.map((item) {
                return Text("${item.mallSubName}");
              }).toList()),
        ),
        body: TabBarView(
          controller: _controller,
            children: widget.list.map((item) {
          return ChildProductList(
            bxMallSubDto: item,
          );
        }).toList()),
      ),
    );
  }
  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}
